package at.fhooe.mc.master.clc.server.domain.jdo;

import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import at.fhooe.mc.master.clc.server.domain.AbstractTestable;
import at.fhooe.mc.master.clc.server.domain.ISmallEntity;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class SmallEntityJdo extends AbstractTestable implements ISmallEntity
{
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id; // automatically populated by JDO

	@Persistent
	private String stringField;
	@Persistent
	@Extension(vendorName="datanucleus", key="gae.unindexed", value="true") // JDO extension-annotation for unindexed fields
	private int intField;
	@Persistent
	@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
	private double doubleField;
	@Persistent
	@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
	private Date dateField;
	
	public SmallEntityJdo() {}
	
	public SmallEntityJdo(boolean generate)
	{
		if (generate)
		{
			this.stringField = "String Test Field";
			this.intField = 42;
			this.doubleField = 42.42;
			this.dateField = new Date();
		}
	}

	@Override
	public Long getId()
	{
		return this.id;
	}
	
	@Override
	public String getStringField()
	{
		return this.stringField;
	}

	@Override
	public int getIntField()
	{
		return this.intField;
	}

	@Override
	public double getDoubleField()
	{
		return this.doubleField;
	}

	@Override
	public Date getDateField()
	{
		return this.dateField;
	}
	
	@Override
	public String getDistinguishable()
	{
		return this.stringField;
	}
	
	@Override
	public void setDistinguishable(String uuid)
	{
		this.stringField = uuid;
	}

}
